package com.hy.service.impl;

import com.hy.mapper.DraftMapper;
import com.hy.pojo.Draft;
import com.hy.service.DraftService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DraftServiceImpl  implements DraftService {
    @Autowired
    private DraftMapper draftMapper;
    @Override
    public void createDraft(Draft draft) {
        draft.setCreateTime(new Date());
        draft.setUpdateTime(new Date());
        draftMapper.insert(draft);
    }

    @Override
    public void deleteDraft(Long id) {
        draftMapper.deleteById(id);
    }

    @Override
    public void updateDraft(Draft draft) {
        draft.setUpdateTime(new Date());
        draftMapper.update(draft);
    }

    @Override
    public List<Draft> getDraftById(Long id) {
        return draftMapper.selectById(id);
    }

    @Override
    public List<Draft> getDraftsByUserId(Long userId) {
        return draftMapper.selectByUserId(userId);
    }
}
